import 'package:app/services/dio_manager.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:get/get.dart';

import '../../../services/address.dart';
import 'leave_detail_model.dart';

class LeaveDetailController extends GetxController{

  LeaveDetailModel? model;

  /// 获取详情
  requestDataWithDetail()async{

    // var params = {
    //   'company_id':company_id
    // };
    var json = await DioManager().kkRequest('${Address.hrLeaveRead}/${Get.arguments}',method: 'get');

    LeaveDetailModel _model = LeaveDetailModel.fromJson(json);

    model = _model;

    update();
  }
  
  /// 撤销请假
  requestDataCancelLeave()async{
    var params = {
      'leave_id':model?.data?.id
    };
    var json = await DioManager().kkRequest(Address.hrLeaveCancelWrite,bodyParams:params);

    BotToast.showText(text: json['message']);

    requestDataWithDetail();

  }
  
  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    requestDataWithDetail();
  }
}